/////////////////////////////////////////////////////////////////
//	File Name	:	"CCodeProfiler.cpp"
//
//	Author Name	:	Adam Marculaitis (AM)
//
//	Purpose		:	A class to handle the starting and stoping of 
//					queryperformancecounter
/////////////////////////////////////////////////////////////////
#include "CCodeProfiler.h"
#include "CSavedInfo.h"
#include <windows.h>
#pragma comment (lib, "winmm.lib")
#include <iostream>
#include <fstream>
#include <string>
using namespace std;


CCodeProfiler* CCodeProfiler::m_nInstance = NULL;

CCodeProfiler::CCodeProfiler()
{
	LARGE_INTEGER m_Freq;

	QueryPerformanceFrequency(&m_Freq);

	CSavedInfo::GetInstance()->SetFreq(m_Freq);
}
CCodeProfiler::~CCodeProfiler()
{
	if(m_nInstance != NULL)
	{
		delete m_nInstance;
		m_nInstance = NULL;
	}
}
void CCodeProfiler::Start(string szName)
{
	LARGE_INTEGER m_StartTime;
	QueryPerformanceCounter(&m_StartTime);

	CSavedInfo::GetInstance()->StartTime(szName, m_StartTime); 
}
void CCodeProfiler::Stop(string szName)
{
	LARGE_INTEGER StopTime;

	QueryPerformanceCounter(&StopTime);

	CSavedInfo::GetInstance()->StopTime(szName, StopTime); 
}

CCodeProfiler* CCodeProfiler::GetInstance()
{
	if(m_nInstance == NULL)
	{
		m_nInstance = new CCodeProfiler;
	}
	return m_nInstance;
}
